function ExportMacro(exp_vars)


MacFileLocation = get_nmr_directory().."/mac/"..get_out_macro()
--print("AAA"..MacFileLocation)
outfile = io.output( MacFileLocation)

local pathway
pathway=get_nmr_directory()

--for k in string.gfind(MacFileLocation, "(.*)/") do
--if(k) then pathway=k end
--print(k)
--end
--print(pathway)
if(exp_vars["xcpr"]) then --write dimensionality first
outfile:write( "\nxcpr "..exp_vars["xcpr"] )
end

for key, value in pairs( exp_vars ) do
if(string.find(key,"(%s*)script(%d-)")) then 
print("Parsed out: "..key.." "..value)
else
outfile:write( "\n"..key.." "..value ) 
end
end

outfile:close()
local accum=""
accum=accum.."\n##########\n"
accum=accum.."Macro file for TopSpin "..MacFileLocation.." is written.\n"
accum=accum.."Link these files to TopSpin file structure as suggested:"
accum=accum.."\n\n\n"

accum=accum.."ln -s "..MacFileLocation.." "..spectrometer[now].home_topspin.."/mac\n"

for key, value in pairs( exp_vars ) do
if  string.find( key,"cpdprg" ) then
accum=accum.."ln -s "..pathway.."/cpd/"..exp_vars[key].." "..spectrometer[now].home_topspin.."/cpd\n"
end
end

for key, value in pairs( exp_vars ) do
if  string.find( key,"pulprog" ) then
accum=accum.."ln -s "..pathway.."/pp/"..exp_vars[key].." "..spectrometer[now].home_topspin.."/pp\n"
end
end

for key, value in pairs( exp_vars ) do
if  string.find( key,"spnam" ) then
accum=accum.."ln -s "..pathway.."/wave/"..exp_vars[key].." "..spectrometer[now].home_topspin.."/wave\n"
accum=accum.."\n"
end
end 
print(accum)
answ=dlg.getSymbol("Macro for TS written",MacFileLocation,"View macro","View info","continue")
if(answ=="View macro") then
			local accumulator=""
			for line in io.lines(MacFileLocation) do
				if(line) then accumulator=accumulator..line.."\n" end
			end
			add_string_to_body_of_currentsettings(accumulator)
			show_currentsettings()
end --if(answ=="View macro")
if(answ=="View info") then
			add_string_to_body_of_currentsettings(accum)
			show_currentsettings()

end

end --fucntion ExportMacro
